﻿using System;
using FlatRedBall;
using Microsoft.Xna.Framework.Input;
using RobotVsZombies.Screens;
using Rvz.Game.Main.Common;
using Keyboard = FlatRedBall.Input.Keyboard;
using Mouse = FlatRedBall.Input.Mouse;

namespace Rvz.Game.Main.Inputs
{
    public class RationalizedPcInput : IRationalizedInputDevice
    {
        private readonly Keyboard _keyboard;
        private readonly Mouse _mouse;

        public RationalizedPcInput(Keyboard keyboard, Mouse mouse)
        {
            _keyboard = keyboard;
            _mouse = mouse;
        }

        public float MoveX
        {
            get
            {
                if (_keyboard.KeyDown(Keys.A))
                { return -1; }
                if (_keyboard.KeyDown(Keys.D))
                { return 1; }

                return 0;
            }
        }

        public float MoveY
        {
            get
            {
                if (_keyboard.KeyDown(Keys.W))
                { return 1; }
                if (_keyboard.KeyDown(Keys.S))
                { return -1; }

                return 0;
            }
        }

        public float TurnX
        {
            get { return _mouse.XChange; }
        }

        public float TurnY
        {
            get { return _mouse.YChange; }
        }

        public int TurnSensitivity
        {
            get { return 6; }
        }

        public float FireTrigger
        {
            get { return Convert.ToInt32(_mouse.ButtonDown(Mouse.MouseButtons.LeftButton)); }
        }
    }
}